package com.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.entity.ClassAndUser;
import com.entity.ClassEvaluation;
import com.entity.ClassInfo;
import com.entity.Department;
import com.entity.EvaItems;
import com.entity.UploadVo;
import com.entity.User;
import com.entity.UserRole;
import com.service.ClassService;
import com.service.DepartmentService;
import com.service.UserService;
import com.util.ExcelMultipartFile;


/**
 * 用户请求处理层
 */
@Controller
@RequestMapping("/user")
public class ALLController {
	@Autowired
	private UserService userService;
	@Autowired
	private ClassService classService; 
	@Autowired 
	private DepartmentService departmentService;

	@RequestMapping("/user")
	public String user() throws Exception {
		return "user/admin_login";
	}

	/**
	 * 用户登录
	 */
	@RequestMapping("/login.action")
	@ResponseBody
	public void login(HttpServletRequest request, HttpServletResponse response, String username, String password) throws Exception {
		response.setCharacterEncoding("UTF-8");
		response.setHeader("content-type", "text/html;charset=UTF-8");
		User user = userService.getUserByLogin(username, password);
		String info = "";
		HttpSession session = request.getSession();
		if (user != null) {
			session.setAttribute("username", user.getUsername());
			session.setAttribute("userId", user.getId());
			info = "登录成功";
//			request.setAttribute("user", user);
//			request.getRequestDispatcher("/user/userlist.action").forward(request, response);
			response.getWriter().print(user.getId());
		} else {
			info = "登录失败，请确认帐号或密码是否正确!";
			response.getWriter().print(info);
		}
	}

	/**
	 * 显示用户操作界面
	 */
	@RequestMapping("/userlist.action")
	@ResponseBody
	public ModelAndView userlist(Model model, HttpServletRequest request, HttpServletResponse response, Long userId,String btn) throws Exception {
		User user = userService.getUserById(userId);
		model.addAttribute("user", user);
		//获取教师对应课程（id）列表，供获取二维码使用
		User userQuery = new User();
		userQuery.setId(userId);
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getClassInfoByUserId(userQuery);
		model.addAttribute("classList", classList);
		model.addAttribute("btn",btn);
		return new ModelAndView("user/admin_user");
	}
	
	/**
	 * 显示修改用户操作页面（学生）
	 */
	@RequestMapping("/edit")
	public ModelAndView edit(Model model, Long id) throws Exception {
		User user = userService.getUserById(id);
		model.addAttribute("user", user);
		List<Department> departmentList = new ArrayList<Department>();
		departmentList = departmentService.getAllDepartment();
		model.addAttribute("departmentList", departmentList);
		return new ModelAndView("user/admin_user_edit");
	}
	
	/**
	 * 课程信息(学生、教师)
	 */
	@RequestMapping("/stu_class_info")
	public ModelAndView getClassInfoByStudent(Model model, Long id, String className) throws Exception {
		User user = userService.getUserById(id);
		model.addAttribute("user", user);
		User userQuery = new User();
		userQuery.setId(id);
		userQuery.setClassName(className);
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getClassInfoByUserId(userQuery);
		model.addAttribute("classList", classList);
		return new ModelAndView("class/admin_class_info");
	}
	

	/**
	 * 修改用户信息(学生)
	 */
	@RequestMapping("/edit_do")
	public String edit_do(Long userId,String username,String userCode,Long departmentId,Integer sex,String email,String phone,String nickName,String password) throws Exception {
		User user = new User();
		user.setId(userId);
		user.setNickName(nickName);
		user.setUsername(username);
		user.setPassword(password);
		user.setUserCode(userCode);
		user.setDepartment(departmentId);
		user.setSex(sex);
		user.setEmail(email);
		user.setPhone(phone);
		userService.modUserBySubmit(user);
		return "forward:userlist.action";
	}
	
	/**
	 * 评价信息(学生)
	 */
	@RequestMapping("/stu_class_evaluation_info")
	public ModelAndView getClassEvaluationInfoByStudent(Model model, Long id) throws Exception {
		User user = userService.getUserById(id);
		model.addAttribute("user", user);
		
		User userQuery = new User();
		userQuery.setId(id);
		List<ClassEvaluation> classEvaluationList = new ArrayList<ClassEvaluation>();
		classEvaluationList = classService.getClassEvaluationInfoByUserId(userQuery);
		  
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
		for(ClassEvaluation e : classEvaluationList){
			String str=sdf.format(e.getAddTime()); 
			e.setStrTime(str);
		}
		model.addAttribute("classEvaluationList", classEvaluationList);
		return new ModelAndView("class/stu_class_evaluation_info");
	}
	
	/**
	 * 获取学生信息列表
	 */
	@RequestMapping("/getStuList")
	@ResponseBody
	public Object getStuList(HttpServletRequest request,HttpServletResponse response, Long id, Long classId) throws Exception {
		//获取学生列表
		User user = new User();
		user.setClassId(classId);
		user.setId(id);
		user.setUserType(1);
		List<User> stuList = userService.getUserListByUser(user);
		User uq = new User();
		uq.setClassId(classId);
		for(User u : stuList){
			uq.setId(u.getId());
			Integer evaTimes = userService.getEvaTimes(uq);
			u.setEvaTime(evaTimes);
		}
		return stuList;
	}
	
	
	/**
	 * 评价信息(教师)
	 */
	@RequestMapping("/tea_evaluation_info")
	@ResponseBody
	public ModelAndView getClassInfoByTea(Model model, Long id, String className) throws Exception {
		User user = userService.getUserById(id);
		model.addAttribute("user", user);
		User userQuery = new User();
		userQuery.setId(id);
		userQuery.setClassName(className);
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getClassInfoByUserId(userQuery);
		
		User userQuery2 = new User();
		userQuery2.setId(id);
		List<ClassEvaluation> classEvaluationList = new ArrayList<ClassEvaluation>();
		classEvaluationList = classService.getClassEvaluationInfoForTea(userQuery2);
		for(ClassInfo cycle : classList){
			Long classId = cycle.getId();
			Integer aveScore = 0;
			Integer sum = 0;
			Integer count = 0;
			for(ClassEvaluation c : classEvaluationList){
				if(c.getClassId().equals(classId)){
					sum += c.getScore();
					count ++;
				}
			}
			if(count == 0){
				aveScore = 0;
			}else{
				aveScore = sum/count;
			}
			cycle.setAveScore(aveScore);
		}
		model.addAttribute("classList", classList);
		model.addAttribute("classEvaluationList", classEvaluationList);
		return new ModelAndView("class/tea_eva_list");
	}
	
	/**
	 * 学生扫码登录系统
	 */
	@RequestMapping("/loginByPhone")
    @ResponseBody
    public ModelAndView getLoginByPhone(Model model, HttpServletRequest request, Long classId,String info,Integer class_count){
		model.addAttribute("classId", classId);
		model.addAttribute("class_count", class_count);
        return new ModelAndView("/login_by_phone");
    }
	
	/**
	 * 用户登录（手机扫码登录）
	 */
	@RequestMapping("/confirmLoginByPhone.action")
	@ResponseBody
	public ModelAndView confirmLoginByPhone(Model model, HttpServletRequest request, HttpServletResponse response, String username, String password, Long classId,Integer class_count) throws Exception {
		response.setCharacterEncoding("utf-8");//设置传输到前端内容格式
		response.setHeader("content-type", "text/html;charset=UTF-8");//通过设置响应头，控制浏览器以utf-8的格式读取响应数据。
		
		User user = userService.getUserByLogin(username, password);
		String info = "";
		HttpSession session = request.getSession();
		if (user != null) {
			session.setAttribute("username", user.getUsername());
			session.setAttribute("userId", user.getId());
			info = "登录成功";
			return this.evaClass(model, request, classId, info,user.getId(),class_count);
		} else {
			info = "登录失败，请确认帐号或密码是否正确!";
			response.sendRedirect("/login_by_phone.jsp?info="+info);
			//response.getWriter().print(info);
			return null;
		}
	}
	
	/**
	 * 课堂评价页面
	 */
	@RequestMapping("/evaClass")
    @ResponseBody
    public ModelAndView evaClass(Model model, HttpServletRequest request, Long classId,String info,Long userId,Integer class_count)throws Exception {
		User user = userService.getUserById(userId);
		model.addAttribute("user", user);
		model.addAttribute("class_count", class_count);
		//获取课堂信息
		User userQuery = new User();
		userQuery.setId(userId);
		userQuery.setClassId(classId);
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getClassInfoByUserId(userQuery);
		model.addAttribute("cl", classList.get(0));
		//获取评价标准
		List<EvaItems> evaItemsList = classService.getEvaItems(new EvaItems());
		model.addAttribute("evaItemsList", evaItemsList);		
        return new ModelAndView("/admin_user_edit_phone");
    }
	
	/**
	 * 提交课堂评价
	 */
	@RequestMapping("/add_eva")
	public void add_eva(Long userId,Integer score,Long teacherId,String remark,Long classId,
			HttpServletRequest request,HttpServletResponse response,Integer class_count) throws Exception {
		ClassEvaluation ce = new ClassEvaluation();
		ce.setUserId(userId);
		ce.setClassId(classId);
		ce.setScore(score);
		ce.setRemark(remark);
		ce.setClass_count(class_count);
		userService.addEva(ce);
		response.setCharacterEncoding("UTF-8");
		response.setHeader("content-type", "text/html;charset=utf-8");
		response.getWriter().println("评价成功！");
	}
	
	/**
	 * 用户列表
	 */
	@RequestMapping("/allUserlist.action")
	@ResponseBody
	public ModelAndView getUserlist(Model model, HttpServletRequest request, HttpServletResponse response, Long id,User user) throws Exception {
		User oper_user = userService.getUserById(id);
		model.addAttribute("user", oper_user);
		//获取所有用户
		List<User> userList = new ArrayList<User>();
		userList = userService.getAllUsers(user);
		model.addAttribute("userList", userList);
		
		List<UserRole> roleList = new ArrayList<UserRole>();
		roleList = userService.getUserRoleList();
		model.addAttribute("roleList", roleList);
		Integer userType = user.getUserType();
		model.addAttribute("ut", userType);
		String nname = user.getNickName();
		model.addAttribute("nname", nname);
		return new ModelAndView("user/admin_user_list");
	}
	
	/**
	 * 添加用户页面
	 */
	@RequestMapping("/addUser")
	public ModelAndView addUser(Model model, Long id) throws Exception {
		User user = userService.getUserById(id);
		model.addAttribute("user", user);
		//获取角色列表（供前端选择添加）
		List<UserRole> userRoleList = new ArrayList<UserRole>();
		userRoleList = userService.getUserRoleList();
		model.addAttribute("userRoleList", userRoleList);
		//获取专业、院系列表（供前端选择添加）
		List<Department> departmentList = new ArrayList<Department>();
		departmentList = departmentService.getAllDepartment();
		model.addAttribute("departmentList", departmentList);
		return new ModelAndView("user/admin_user_add");
	}
	
	/**
	 * 添加用户
	 */
	@RequestMapping("/add_user")
	@ResponseBody
	public ModelAndView add_eva(Model model,HttpServletRequest request,HttpServletResponse response, User user) throws Exception {
		userService.add(user);
		return this.getUserlist(model, request, response, user.getAdderId(),new User());
	}
	
	/**
	 * 显示修改用户页面（管理员）
	 */
	@RequestMapping("/edit_user")
	public ModelAndView modUserPage(Model model,Long id,Long operatorId) throws Exception {
		User operator = userService.getUserById(operatorId);
		model.addAttribute("operator", operator);
		User userinfo = userService.getUserById(id);
		model.addAttribute("userinfo", userinfo);
		//获取角色列表（供前端选择添加）
		List<UserRole> userRoleList = new ArrayList<UserRole>();
		userRoleList = userService.getUserRoleList();
		model.addAttribute("userRoleList", userRoleList);
		List<Department> departmentList = new ArrayList<Department>();
		departmentList = departmentService.getAllDepartment();
		model.addAttribute("departmentList", departmentList);
		return new ModelAndView("user/admin_mod_user");
	}
	
	/**
	 * 修改用户信息(管理员)
	 */
	@RequestMapping("/modUserBySubmit")
	public ModelAndView modUser(Model model,HttpServletRequest request,HttpServletResponse response, User user) throws Exception {
		userService.modUserBySubmit(user);
		return this.getUserlist(model, request, response, user.getAdderId(),new User());
	}
	
	/**
	 * 删除用户信息(管理员)
	 */
	@RequestMapping("/delUser")
	public ModelAndView delUser(Model model,HttpServletRequest request,HttpServletResponse response, Integer id,Long operatorId) throws Exception {
		userService.delete_do(id);
		return this.getUserlist(model, request, response, operatorId,new User());
	}
	
	/**
	 * 管理查询评价信息页面
	 */
	@RequestMapping("/getAllClassInfo")
	public ModelAndView getAllClassInfo(Model model,HttpServletRequest request,HttpServletResponse response,Long operatorId) throws Exception {

		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getAllClassInfo();
		model.addAttribute("classList", classList);
		for(ClassInfo c : classList){
			//获取该课程评价总人数
			Integer allEvaPeople = 0;
			//获得该课程的评价总分数（平均分）
			Integer aveScore = 0;
			Long classId = c.getId();
			allEvaPeople = classService.getAllEvaPeople(classId);
			c.setAllEvaPeople(allEvaPeople);
			
			List<ClassEvaluation> ceList = classService.getEvainfo(classId);
			c.setCeList(ceList);
			for(ClassEvaluation ce : ceList){
				aveScore += ce.getScore();
			}
			if(null == ceList || ceList.size() < 1 ){
				aveScore = 0;
			}else{
				aveScore = aveScore/ceList.size();
			}
			c.setAveScore(aveScore);
		}
		return new ModelAndView("class/admin_class_info");
	}
	
	/**
	 * 获取评价信息列表
	 */
	@RequestMapping("/getEvaList")
	@ResponseBody
	public Object getEvaList(HttpServletRequest request,HttpServletResponse response, Long id, Long classId) throws Exception {
		List<ClassEvaluation> ceList = classService.getEvainfo(classId);
		return ceList;
	}
	
	/**
	 * 添加课程信息页面
	 */
	@RequestMapping("/addClassInfoPage")
	public ModelAndView addClassInfoPage(Model model, Long operatorId) throws Exception {
		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		return new ModelAndView("class/admin_class_add");
	}
	
	/**
	 * 添加课程信息
	 */
	@RequestMapping("/addClass")
	public ModelAndView addClassInfo(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,String className,String class_introduce,Integer class_sum) throws Exception {
		classService.addClass(className,class_introduce,class_sum);
		return this.userlist(model, request, response, userId,null);
	}
	
	/**
	 * 文件下载
	 */
	@RequestMapping("download")
	public void download(HttpServletRequest request, HttpServletResponse response, String path) throws IOException {
		StringBuilder pathSb = new StringBuilder();
		pathSb.append(request.getServletContext().getRealPath("/"));
		pathSb.append("res/");
		pathSb.append(path);
		String filePath = pathSb.toString();
		File file = new File(filePath);
		InputStream is = null;
		OutputStream os = null;
		try {
			is = new FileInputStream(file);
			String fileName = file.getName();
			response.setCharacterEncoding("UTF-8");
			response.setContentType("multipart/form-data");
			response.setHeader("content-disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"), "ISO8859-1"));
			os = response.getOutputStream();
			byte[] b = new byte[1024];
			int length;
			while ((length = is.read(b)) > 0) {
				os.write(b, 0, length);
			}
		} catch (IOException e) {
			throw e; // 向上级抛出异常，使程序终止，前台页面报错
		} finally {
			try {
				if (is != null) {
					is.close();
				}
				if (os != null) {
					os.close();
				}
			} catch (IOException e) {
				throw e;
			}
		}
	}
	
	/**
     * 导入课程预览
     */
	@SuppressWarnings("deprecation")
	@RequestMapping("/uploadClassReview")
	public ModelAndView uploadClassReview(Model model, HttpServletRequest request,MultipartFile uploadFile,Long operatorId)throws Exception {
		ExcelMultipartFile excelMultipartFile = new ExcelMultipartFile(request, uploadFile,"维护评价系统");
		ExcelMultipartFile.ExcelInfo excelInfo = excelMultipartFile.getExcelInfo();
		Map<String, Object> map=new HashMap<>();
		if(null !=excelInfo && ! excelInfo.getRows().isEmpty()){
			if(excelInfo.getRows().size() >= 502) {
				model.addAttribute("errorMsg", "最多允许上传500条记录");
			}else {
				List<List<String>> rows=excelInfo.getRows();
				map=classService.getImportClassDetails(rows);
			} 
		}
		model.addAttribute("classList", map.get("classList"));
		model.addAttribute("isSubmit", map.get("isSubmit"));
		
		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		return new ModelAndView("/class/admin_upload_class_review");
	}
	
	/**
	 * 导入课程信息
	 */
	@RequestMapping("/uploadClass")
	public ModelAndView addClassInfoByUpload(Model model, HttpServletRequest request,HttpServletResponse response,
			Long userId,UploadVo uploadVo) throws Exception {
		for(ClassInfo ci : uploadVo.getClassList()){
			classService.addClass(ci.getName(),ci.getClass_introduce(),ci.getClass_sum());
		}
		return this.userlist(model, request, response, userId, null);
	}
	
	/**
     * 导入用户预览
     */
	@SuppressWarnings("deprecation")
	@RequestMapping("/uploadUserReview")
	public ModelAndView uploadUserReview(Model model, HttpServletRequest request,MultipartFile uploadUserFile,Long operatorId)throws Exception {
		ExcelMultipartFile excelMultipartFile = new ExcelMultipartFile(request, uploadUserFile,"维护评价系统");
		ExcelMultipartFile.ExcelInfo excelInfo = excelMultipartFile.getExcelInfo();
		Map<String, Object> map=new HashMap<>();
		if(null !=excelInfo && ! excelInfo.getRows().isEmpty()){
			if(excelInfo.getRows().size() >= 502) {
				model.addAttribute("errorMsg", "最多允许上传500条记录");
			}else {
				List<List<String>> rows=excelInfo.getRows();
				
				map=userService.getImportUserDetails(rows);
			} 
		}
		model.addAttribute("userList", map.get("userList"));
		model.addAttribute("isSubmit", map.get("isSubmit"));
		
		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		return new ModelAndView("/user/admin_upload_user_review");
	}
	
	/**
	 * 导入用户信息
	 */
	@RequestMapping("/uploadUser")
	public ModelAndView uploadUser(Model model, HttpServletRequest request,HttpServletResponse response,
			Long userId,UploadVo uploadVo) throws Exception {
		for(User u : uploadVo.getUserList()){
			userService.add(u);
		}
		return this.userlist(model, request, response, userId,null);
	}
	
	/**
	 * 返回一个code
	 */
	@RequestMapping("/getCode")
	public void getCode(HttpServletRequest request,HttpServletResponse response)throws Exception{
		response.getWriter().print("i_love_you");
	}
	
	/**
	 * 首页修改密码
	 */
	@RequestMapping("/modPwd")
	public ModelAndView modPwd(Model model, HttpServletRequest request,HttpServletResponse response,Long operatorId,String password) throws Exception {
		//修改密码
		User user = new User();
		user.setId(operatorId);
		user.setPassword(password);
		userService.modUserBySubmit(user);
		return this.userlist(model, request, response, operatorId, null);
	}
	
	/**
	 * 评价标准列表
	 */
	@RequestMapping("/addEvaItemsPage")
	public ModelAndView addEvaItemsPage(Model model, HttpServletRequest request,HttpServletResponse response,Long operatorId,Long adderId) throws Exception {
		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		
		//根据用户类型和id获取评价标准
		List<EvaItems> evaItemList = new ArrayList<EvaItems>();
		Integer userType = user.getUserType();
		EvaItems eiqu = new EvaItems();
		if(adderId != null)eiqu.setChooseId(adderId);
		if(userType == 2){//教师
			eiqu.setAdderId(operatorId);
		}
		Integer eiCounts = 0;
		evaItemList = classService.getEvaItems(eiqu);
		if(evaItemList != null && evaItemList.size()>0){
			for(EvaItems e:evaItemList){
				if(user.getUserType() == e.getUserType()){
					eiCounts += 1;
				}
			}
		}
		model.addAttribute("evaItemList", evaItemList);
		model.addAttribute("eiCounts",eiCounts);
		return new ModelAndView("class/admin_eva_items_list");
	}
	
	/**
	 * 修改评价标准页面
	 */
	@RequestMapping("/modEiPage")
	public ModelAndView modEiPage(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,Long eiId) throws Exception {
		User user = userService.getUserById(userId);
		model.addAttribute("user", user);
		if(eiId != null){//更新
			EvaItems ei = new EvaItems();
			ei.setId(eiId);
			ei = classService.getEvaItems(ei).get(0);
			model.addAttribute("ei", ei);
		}
		return new ModelAndView("class/admin_ei_mod");
	}
	
	/**
	 * 修改评价标准
	 */
	@RequestMapping("/modEi")
	public ModelAndView modEi(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,Long eiId,String eiName) throws Exception {
		EvaItems ei = new EvaItems();
		ei.setId(eiId);
		ei.setName(eiName);
		ei.setAdderId(userId);
		classService.modEI(ei);
		return this.addEvaItemsPage(model, request, response, userId,null);
	}
	
	/**
	 * 删除评价标准
	 */
	@RequestMapping("/delEi")
	public ModelAndView delEi(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,Long eiId) throws Exception {
		classService.delEI(eiId);
		return this.addEvaItemsPage(model, request, response, userId,null);
	}
	
	/**
	 * 新增评价标准页面
	 */
	@RequestMapping("/addEiPage")
	public ModelAndView addEiPage(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,Long eiId) throws Exception {
		User user = userService.getUserById(userId);
		model.addAttribute("user", user);
		return new ModelAndView("class/admin_ei_add");
	}
	
	/**
	 * 新增评价标准
	 */
	@RequestMapping("/addEi")
	public ModelAndView addEi(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,EvaItems ei) throws Exception {
		classService.addEI(ei);
		return this.addEvaItemsPage(model, request, response, userId,null);
	}
	
	/**
	 * 添加课程对用用户信息页面
	 */
	@RequestMapping("/addClassAndUserPage")
	public ModelAndView addClassAndUserPage(Model model, Long operatorId) throws Exception {
		User user = userService.getUserById(operatorId);
		model.addAttribute("user", user);
		//获取教师对应课程（id）列表，供获取二维码使用
		List<ClassInfo> classList = new ArrayList<ClassInfo>();
		classList = classService.getAllClassInfo();
		model.addAttribute("classList", classList);
		
		//获取全部用户
		List<User> userList = new ArrayList<User>();
		userList = userService.getAllUsers(new User());
		model.addAttribute("userList", userList);
		
		
		return new ModelAndView("class/admin_class_user_add");
	}
	
	/**
	 * 添加课程对用用户信息
	 */
	@RequestMapping("/addClassAndUser")
	public ModelAndView addClassAndUser(Model model, HttpServletRequest request,HttpServletResponse response,Long userId,Long classId,Long operatorId,Integer class_status) throws Exception {
		ClassAndUser cu = new ClassAndUser();
		cu.setClass_status(class_status);
		cu.setClassId(classId);
		cu.setUserId(userId);
		cu.setClass_status(class_status);
		classService.addClassAndUser(cu);
		return this.userlist(model, request, response, operatorId, null);
	}
}
